﻿unit PmItemDataService;

interface
{$I ../Config.inc}
uses
  FastMM4,
  FastMove,
  System.SysUtils,
  System.Classes,
  System.Types,
  Winapi.Windows,
  Data.DB,
  Data.Win.ADODB,
  Datasnap.DBClient,
  Datasnap.Provider,
  {$IFDEF UNICODE}
  AnsiStrings,
  {$ENDIF }
  QBParcel,
  DllSpread,
  Generics.Collections,
  DateUtils,
  QJson,
  UserConnection,
  DBAccessor,
  DllPlugin,
  StrUtils,
  SK0001Comm,
  PmItemDataModel,
  PmItemDataBLL;
  
type


  TPmItemDataService = class(TPmItemDataBLL)
  private

  protected

  public
  {$IFDEF SERVER}
    function BeforeTreatment(const iItem:TPmItemData; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;overload;override;
    function BeforeTreatment(const iItems:TPmItemDataList; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;overload;override;

    function BeforeCheck(const iItem:TPmItemData; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;overload;override;
    function BeforeCheck(const iItems:TPmItemDataList; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;overload;override;

    function Check(const iItem:TPmItemData; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;overload;override;
    function Check(const iItems:TPmItemDataList; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;overload;override;

    function BeforeExecute(const iItem:TPmItemData; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;overload;override;
    function BeforeExecute(const iItems:TPmItemDataList; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;overload;override;

    function AfterTreatment(const iItem:TPmItemData; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;overload;override;
    function AfterTreatment(const iItems:TPmItemDataList; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;overload;override;
  {$ENDIF}
    function LoadByItemNo(const iItemNo:string; const iItem:TPmItemData; out oError:string):Boolean;
  end;
  
implementation

{$IFDEF SERVER}
function TPmItemDataService.BeforeTreatment(const iItem:TPmItemData; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;
begin
  Result:=True;
end;

function TPmItemDataService.BeforeTreatment(const iItems:TPmItemDataList; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;
begin
  Result:=True;
end;

function TPmItemDataService.BeforeCheck(const iItem:TPmItemData; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;
begin
  Result:=True;
end;

function TPmItemDataService.BeforeCheck(const iItems:TPmItemDataList; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;
begin
  Result:=True;
end;

function TPmItemDataService.Check(const iItem:TPmItemData; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;
begin
  Result:=True;
end;

function TPmItemDataService.Check(const iItems:TPmItemDataList; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;
begin
  Result:=True;
end;

function TPmItemDataService.BeforeExecute(const iItem:TPmItemData; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;
begin
  Result:=True;
end;

function TPmItemDataService.BeforeExecute(const iItems:TPmItemDataList; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;
begin
  Result:=True;
end;

function TPmItemDataService.AfterTreatment(const iItem:TPmItemData; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;
begin
  Result:=True;
end;

function TPmItemDataService.AfterTreatment(const iItems:TPmItemDataList; const iPreMode:ePretreatmentMode; const iParcel:TQBParcel; out oError:string):Boolean;
begin
  Result:=True;
end;
{$ENDIF}

function TPmItemDataService.LoadByItemNo(const iItemNo:string; const iItem:TPmItemData; out oError:string):Boolean;
var
  Condition:string;
begin
  if not SameStr(iItemNo,EmptyStr) and (iItem<>nil) then
  begin
    Condition:=Format(string('%s=''%s'''),[TPmItemDataModel.cItemNoKey,iItemNo]);

    if not LoadByCondition(iItem,Condition,oError) then
    begin
      Result:=False;
      Exit;
    end;
  end else begin
    oError:=Format(string('调用TPmItemDataService.LoadByItemNo方法失败！错误内容:传入的iItemNo或iItem为空!'),[]);
    Result:=False;
    Exit;
  end;
  Result:=True;
end;
  
end.
